package cn.laike.modules.dev.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import cn.laike.common.utils.PageUtils;
import cn.laike.common.utils.Query;

import cn.laike.modules.dev.dao.HotelRoomBannerDao;
import cn.laike.modules.dev.entity.HotelRoomBannerEntity;
import cn.laike.modules.dev.service.HotelRoomBannerService;


@Service("hotelRoomBannerService")
public class HotelRoomBannerServiceImpl extends ServiceImpl<HotelRoomBannerDao, HotelRoomBannerEntity> implements HotelRoomBannerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
    	
    	String hotelId = (String)params.get("hotelId");	
    	String hotelRoomId = (String)params.get("hotelRoomId");	
        Page<HotelRoomBannerEntity> page = this.selectPage(
                new Query<HotelRoomBannerEntity>(params).getPage(),
                new EntityWrapper<HotelRoomBannerEntity>()
                .eq(StringUtils.isNotBlank(hotelId),"hotel_id", hotelId)  
                .eq(StringUtils.isNotBlank(hotelRoomId),"hotel_room_id", hotelRoomId)  
                .orderBy("sort", false)
        );

        return new PageUtils(page);
    }

	@Override
	public List queryBannerList(Integer hotelId, Integer hotelRoomId) {
		return baseMapper.queryBannerList(hotelId, hotelRoomId);
	}

}
